<template>
 <section>
   <el-table :data="tableData" highlight-current-row   style="width: 100%;">
     <el-table-column type="selection" width="55">
     </el-table-column>
     <el-table-column type="index" width="60">
     </el-table-column>

     <el-table-column prop="id" label="商品ID" width="160" sortable>
     </el-table-column>

     <el-table-column prop="goodsName" label="商品名称" width="160" sortable>
     </el-table-column>

     <el-table-column prop="price" label="商品价格" width="160" sortable>
     </el-table-column>

     <el-table-column prop="categoryNames.category1" label="一级分类" width="160" sortable>
     </el-table-column>

     <el-table-column prop="categoryNames.category2" label="二级分类" width="160" sortable>
     </el-table-column>

     <el-table-column prop="categoryNames.category3" label="三级分类" width="160" sortable>
     </el-table-column>

     <el-table-column prop="auditStatus" label="状态" width="160" sortable>
       <template scope="scope">
          <span v-if="scope.row.auditStatus=='1'">
              审核通过
          </span>
         <span v-else-if="scope.row.auditStatus=='0'">
              待审核
          </span>
         <span v-else-if="scope.row.auditStatus=='2'">
              已驳回
          </span>
         <span v-else-if="scope.row.auditStatus=='3'">
              审核中
          </span>
       </template>
     </el-table-column>

     <el-table-column label="操作">
       <template scope="scope">
         <el-button size="small" :disabled="scope.row.auditStatus!='0'&& scope.row.auditStatus!='2' " @click="handleEdit(scope.row)">审核</el-button>
       </template>
     </el-table-column>
   </el-table>
 </section>
</template>

<script>
export default {
  name: "GoodsView",
 data(){
    return{
        tableData:[],
    }
 },
  methods:{
    queryBySellerId:function () {
      this.$http.get("/goods/api/goods/queryBySellerId")
          .then(resp=>{
            this.tableData=resp.data.data;
          }).catch(resp=>{
        this.$message({
          message: "请登录",
          type: 'error'
        });
      })
    },
    handleEdit:function (row) {
      let parm ={
        id:row.id,
        auditStatus:3
      }
      this.$http.post("/goods/api/goods/updateAuditStatus",parm)
          .then(resp=>{
            this.$message({
              message: "操作成功",
              type: 'success'
            });
            location.reload();
          }).catch(resp=>{
        this.$message({
          message: "请登录",
          type: 'error'
        });
      })
    }
  },mounted() {
      this.queryBySellerId();
  }
}
</script>

<style scoped>

</style>